<?php

namespace App\V3\Api\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TextImageTemplatesModel extends Model
{
    use HasFactory;
    const    PAGESIZE  = 20;
    protected $table   = 'album_content_template';

    /**
     * 添加文字内容模板
     */
    static public function addContentTempLate($data){

        return TextImageTemplatesModel::insertGetId($data);

    }
    /**
     * 删除文字内容模板
     */
    static public function delContentTempLate($condition){

        return TextImageTemplatesModel::where($condition)->delete();
    }
    /**
     * 修改文字内容模板
     */
    static public function updateContentTempLate($condition,$data){

        return TextImageTemplatesModel::where($condition)->update($data);
    }
    /**
     * 查询文字内容模板信息
     */
    static public function getTextImageTemplatesInfo($condition){

        return TextImageTemplatesModel::where($condition)->first();
    }

    /**
     * 查询多条内容模板信息
     */
    static public function getTextImageTemplatesInfos($condition,$pa_ids_arr){

        return TextImageTemplatesModel::where($condition)->whereIn('pa_id',$pa_ids_arr)->get()->toArray();;
    }

    /**
     *删除多条文字内容模板
     */
    static public function delContentTempLates($condition,$pa_ids_arr){

        return TextImageTemplatesModel::where($condition)->whereIn('pa_id',$pa_ids_arr)->delete();
    }
    /**
     * 查询文字画册列表
     */
   static public function getContentTempLateList($condition, $currentPage,$pageSize){

       return  TextImageTemplatesModel::select('act.*')->from('album_content_template AS act')
       ->leftJoin('text_image AS ti', 'act.pa_id', '=', 'ti.id')
       ->where($condition)
       ->orderBy('act.create_time', 'DESC')
       ->paginate($pageSize, '',$currentPage)
       ->toArray();
   }

   /**
    * 查询文字画册列表
    */
   static public function getContentTempLateList02($condition){

       return  TextImageTemplatesModel::select('act.*')->from('album_content_template AS act')
       ->leftJoin('text_image AS ti', 'act.pa_id', '=', 'ti.id')
       ->where($condition)
       ->orderBy('act.create_time', 'DESC')
       ->get();
   }

   /**
    * 查询文字画册列表
    */
   static public function getContentTempLateList03($condition){

       return  TextImageTemplatesModel::select('act.*')->from('album_content_template AS act')
       ->leftJoin('text_image AS ti', 'act.pa_id', '=', 'ti.id')
       ->where($condition)
       ->orderBy('is_top','DESC')
       ->orderBy('act.temp_number', 'ASC')
       ->get()->toArray();
   }
}
